<?php
function includeFile($prefixPath,$name,$postfix='.php') {
	$_file = $prefixPath.$name.$postfix;
	if( file_exists($_file) ) {
		require_once $_file;
	} else {
		$tmp = debug_backtrace();
		trigger_error(Common::recursiveImplode("\n",$tmp),E_USER_WARNING);
		Message::showMessage('__autoload class file '.$name.' not found');
	}
}

function __autoload($name) {
	if( stripos($name,FOLDER_CONFIG) !== FALSE ) {
		includeFile(CONFIG_PATH,$name);
	}
	else if( stripos($name,'base') !== FALSE ) {//base model
		 if( stripos($name,FOLDER_CTL) !== FALSE ) {
			includeFile(LIBS_CTL_PATH,$name);
		 }
		 else if( stripos($name,FOLDER_MODEL) !== FALSE ) {
		 	includeFile(LIBS_MODEL_PATH,$name);
		 }
		 else if( stripos($name,FOLDER_VIEW) !== FALSE ) {
		 	includeFile(LIBS_VIEW_PATH,$name);
		 }else{}
	}
	else if( stripos($name,'smarty') !== FALSE ) {
		includeFile(LIBS_VIEW_PATH,$name,'.class.php');
	}
	else if( stripos($name,FOLDER_CTL) !== FALSE ) {//bbs controller
		includeFile(CTL_PATH,$name);
	}
	else{//OO-Model
		includeFile(MODEL_PATH,$name);
	}
}
?>